package org.hq.util;

import okhttp3.Call;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import static org.junit.jupiter.api.Assertions.*;
@SpringBootTest
class OkHttTest {
    @Autowired
    OkHttps client;
    String url = "https://www.4f4023.com/video/jingpin/";
    @Test
    public void getSync() {
        //同步请求
        Request getRequest = new Request.Builder().url(url).get().build();
        Request.Builder builder = new Request.Builder().url(url).get();

        //准备好请求的Call对象
        Call call = this.client.getClient().newCall(getRequest);
        try {
            Response response = call.execute();

            System.out.println(response.body().string());
            response.body().close();
            call.clone();

        } catch (Exception e) {

        }
    }

}